package cn.china.xfood.controller;


import cn.china.xfood.service.MainService;
import cn.china.xfood.service.UserMenuService;
import entity.Usermenu;
import entity.Userorder;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

import javax.servlet.http.HttpServletResponse;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RestController
public class UsermenuController {

    @Autowired
    UserMenuService userMenuService;



    @RequestMapping("getAllUsermenu")
    public Map<String, Object> getAllUsermenu(HttpServletResponse res, @RequestParam String orderNumber, @RequestParam int page, @RequestParam int limit) {
        res.setHeader("Access-Control-Allow-Origin", "*");


        int i = userMenuService.selectAll(orderNumber);

        int Page = (page - 1) * limit;

        List<Usermenu> list = userMenuService.selectAllMenu(orderNumber, Page, limit);

//        System.out.println(list);
        HashMap<String,Object> map = new HashMap<>();

        map.put("code",0);
        map.put("msg","");
        map.put("count",i);
        map.put("data",list);


//        System.out.println(map);
        return map;

    }



}
